package api

import (
	"github.com/gogf/gf/net/ghttp"
	"shrimp-blog-server/app/model"
)

func (*apiArticle) Get(request *ghttp.Request) {
	articleService.GetArticle(request, getQueryParamID(request)...)
}

func (*apiArticle) Post(request *ghttp.Request) {
	var articles []model.Article
	_ = request.Parse(&articles)
	articleService.AddArticle(request, articles...)

}

func (*apiArticle) Put(request *ghttp.Request) {
	var articles []model.ArticleRequest
	_ = request.Parse(&articles)
	articleService.UpdateArticle(request, articles...)
}

func (*apiArticle) Delete(request *ghttp.Request) {
	articleService.DeleteArticle(request, getQueryParamID(request)...)
}
func (*apiArticle) GetListPage(request *ghttp.Request) {
	var page model.Page
	err := request.Parse(&page)
	if err != nil {
		panic(err)
	}
	if page.Size == 0 {
		page.Size = 10
	}
	if page.Page == 0 {
		page.Page = 1
	}

	articleService.GetArticlePage(request, page)
}
